# -*- coding: utf-8 -*-
from common import trace


class User:
    @trace
    def __new__(cls, *args, **kwargs):
        print('生成实例时调用, 在些可加入生成类的逻辑,用来控制实例的生成过程， 如果__new__不返回对象，则不调用__init__')
        cls.name = 'MyUser'
        return super().__new__(cls)

    @trace
    def __init__(self, name):
        print('初始化实例时调用，此时实例已生成，用来完善实例')
        self.name = name


if __name__ == '__main__':
    user = User(name='jack')
    print(user.name)
    print(User.name)
